package com.scrumtrek.trainings.tdd;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;

//import org.testng.annotations.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
//import static org.testng.AssertJUnit.assertEquals;

/**
 * Created with IntelliJ IDEA.
 * User: msuprunov
 * Date: 21.02.13
 * Time: 11:15
 * To change this template use File | Settings | File Templates.
 */
public class JUnitStoreTestMock {
    private PaySystem paySystem;
    private Store store;

    @Before
    public void HashSetUp() {
        paySystem = mock(PaySystem.class);
        store = new Store(paySystem);
        System.out.println("Test Store HashSetUp");

    }

    public void test1Empty(){
        //Act
        int result = store.getCount();
        //Assert
        assertEquals("Store not empty", 0, result);
    }

    @Test
    public void testStoreAddItem(){
        //Act
        Item item = new Item();
        store.addItem(item);
        //Assert
        assertEquals("Item not added", store.existItem(item), true);
    }

    @Test
    public void testStoreSellItem(){
        //Act
        Item item = new Item();
        store.addItem(item);
        store.sellItem(item);
        //Assert
        assertEquals("Item not sell", store.existItem(item), false);
    }

    @Test
    public void testPaySystem(){
        //Act
        Item item = new Item(100);
        store.addItem(item);
        store.sellItem(item);
        //Assert
        verify(paySystem).increaseProfit(100);
    }

    @After
    public void tearDown(){
        System.out.println("Test Store tearDown");
    }
}
